package src.main.java.org.io;

import java.io.*;

/*
* 字符输出转换流：OutputStreamWriter
* */
public class Test12 {
    public static void main(String[] args) {
        try(
                //1.得到文件的原始字节流（GBK的字节流形式）
                FileOutputStream fileOutputStream = new FileOutputStream("E:\\JavaLearn\\javaCode\\src\\test7.txt");
                //2.把原始的字节输入流按照指定的字符集编码转换成字符输入流
                Writer wsr = new OutputStreamWriter(fileOutputStream,"GBK");
                BufferedWriter bufferedWriter = new BufferedWriter(wsr)
        ) {
           bufferedWriter.write("床前明月光");

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
